#include <bits/stdc++.h>
using namespace std;

void solve() {
    string s, ans;
    for(int i = 0; i < 8; i++) {
        cin >> s;
        for(auto ch : s) {
            if(ch != '.') ans += ch;
        }
    }
    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}